package main
import "fmt"

// 计算1-100的和
func for_test1(){
	sum := 0
	for i := 1; i <= 100; i++ {
		sum += i
	}
	fmt.Println(sum)
}

// for循环 字符串,数组,切片
func for_test2(){
    msg := "hello world"
    for i := 0; i < len(msg); i++ {
        fmt.Printf("%c\n", msg[i])
    }

	names := []string{"lilisi","Jack","Tom"}
	for idx, value := range names {
		fmt.Printf("index:%d, value:%s\n", idx, value)
	}

	data := []int{1,2,3,4,5}
	for _, value := range data {
		fmt.Printf("value:%d\n", value)
	}
}

func main(){
	for_test1()
	for_test2()
}
